import { defineStore } from "pinia";
export const useUserStore = defineStore("userStore", {
    state: () => {
        return {
            roles: [],
            currentRole: "",
            menus: [],
        };
    },
    getters: {
        getCurrentRole: (state) => state.currentRole,
    },
    actions: {
        setRoles(roles: []) {
            this.roles = roles;
            console.log("roles", roles);
        },
        setCurrentRole(currentRole: string) {
            this.currentRole = currentRole;
        },
        setMenus(menus: []) {
            this.menus = menus;
        },
    },
    persist: {
        enabled: true,
        strategies: [
            {
                key: "userStore",
                storage: localStorage,
                paths: ["roles", "currentRole"], // 只对roles、currentRole进行持久化
            },
        ],
    },
});
export default useUserStore;
